from openai import OpenAI
import os

API_KEY = os.environ['KIMI_SECRET']
print(f'API: {API_KEY}')
 
client = OpenAI(
    api_key=API_KEY,
    base_url="https://api.moonshot.cn/v1",
)
 
completion = client.chat.completions.create(
    model = "moonshot-v1-8k",
    messages = [
        {"role": "system", "content": "你是一名经验丰富的新生儿儿科医生"},
        {"role": "user", "content": "四月龄孩子如何避免甲流？"}
    ],
    temperature = 0.3,
)
 
# 通过 API 我们获得了 Kimi 大模型给予我们的回复消息（role=assistant）
print(completion.choices[0].message.content)
